﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using STT.Layer.Connection;
namespace STT.Profilehv
{
    public partial class Default : System.Web.UI.Page
    {
        ToolBox tb = new ToolBox();
        Control ct = new Control();
        string module = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                LoadAvatar();
            if (Session["Mahv"] != null)
                lbltenhv.Text = Session["Mahv"].ToString();
            else
            {
                Response.Redirect("~/Default.aspx");
            }
            HtmlGenericControl gel = new HtmlGenericControl("div");
            if (Request.QueryString["mod"] == null)
            {
                Response.Redirect("Default.aspx?mod=Home");
            }
            else
            {
                module = Request.QueryString["mod"].ToString().Trim();
                //string mod = Request.QueryString["module"].ToString().Trim();

                if (module == "Home")
                {
                    
                    ct = Page.LoadControl("UserControls/UcIndex.ascx");

                }
                else if (module == "TTKH1411")
                {

                    ct = Page.LoadControl("UserControls/UcThongTinKhoaHoc.ascx");

                }
                else if (module == "TTCN117")
                {

                    ct = Page.LoadControl("UserControls/UcThongTinCaNhan.ascx");

                }
                else if (module == "DHV132")
                {

                    ct = Page.LoadControl("UserControls/UcBangDiem.ascx");

                }
                else if (module == "TTGV1303")
                {

                    ct = Page.LoadControl("UserControls/UcThongTinGiangVien.ascx");

                }
                else if (module == "TKB1303")
                {

                    ct = Page.LoadControl("UserControls/UcThoiKhoaBieu.ascx");

                }
                else if (module == "DMK1303")
                {

                    ct = Page.LoadControl("UserControls/UcDoiMatKhau.ascx");

                }
                gel.Controls.Add(ct); plindex.Controls.Add(gel);

            }
        }
        private void LoadAvatar()
        {
            if (Session["Mahv"] != null)
            {
                DtlAvatar.DataSource = tb.GetDataTableById("[Get_HocVien_ByMaHV]", Session["Mahv"].ToString());
                DtlAvatar.DataBind();
            }
            else
            {
                Response.Redirect("~/Default.aspx");
            }
            
        }

        protected void lbtthoat_Click(object sender, EventArgs e)
        {
            Session["namehv"] = null;
            Session["role"] = null;
            Session["Mahv"] = null;
            Response.Redirect("~/Default.aspx");
        }
    }
}